
** EMPLOYMENT **

/*Activities labels*/

	local labshop        "the shop"
    local labtable       "a table at the market"
    local labbuysell     "buying and selling around"
    local labpettytrade  "other petty trade"
    local labtrade       "vocation"
    local laboffice      "office work"
    local labcarload     "carloading"
    local labcarwash     "car washing"
    local labmoto        "peim peim driving"
    local labcarryload   "carried load for money"
    local labguard       "watchman job"
    local labhouseclswp  "brusshing clean cool house boy"
    local labscavenge    "looking for scraps"
    local labbeg         "begging"
    local labfarm        "farming"
    local labdrugsell    "selling drugs"
    local labstealing    "stealing"
    local labgambling    "gambling"
    local labsmallbiz    "a small business (video or barber or shoeshine)"
    local labconstr      "construction work"
    local labfish        "fishing"
    local labgoldrubber  "gold and rubber tapping"
    local labcontract    "contract Work"
    local labother       "other activity"


	// Conversion to hourday

		foreach x in shop table buysell pettytrade trade office carload carwash moto carryload guard houseclswp scavenge beg farm drugsell stealing gambling smallbiz contract constr fish goldrubber other {

			gen `x'7dhrstot_e =  `x'7ddys_e*`x'7dhrs_e
			move `x'7dhrstot_e `x'7ddys_e
             cap label var	`x'7dhrstot_e `"In the last 7 days, how many total hours did you work at `lab`x'' "'

     		gen `x'prev7dhrstot_e =  `x'prev7ddys_e*`x'prev7dhrs_e
			move `x'prev7dhrstot_e `x'prev7ddys_e
		     cap label var `x'prev7dhrstot_e `"In the previous 7 days, how many total hours did you work at `lab`x'' "'

			gen `x'4whrstot_e =  `x'4wdys_e*`x'4whrs_e
			move `x'4whrstot_e `x'4wdys_e

			gen `x'4whrstot_b =  `x'4wdys_b*`x'4whrs_b
			move `x'4whrstot_b `x'4wdys_b
		}

		* Replace missing by 0 (only if question was asked at specific endline)

			foreach x in shop table buysell pettytrade trade office carload carwash moto carryload guard houseclswp scavenge beg farm drugsell stealing gambling smallbiz constr fish goldrubber other {
				replace `x'7dhrstot_e = 0 if `x'7dhrstot_e ==. & (p1_e3wks ==1 | p1_e5m ==1 | p2_e2wks==1 | p2_e2w2w==1 | p1_e7m ==1  | p1_e12m ==1 | p1_e13m ==1 | p3_e2w==1 | p3_e5w==1 | p2_e12m ==1 | p2_e13m ==1 | p3_e12m ==1 | p3_e13m ==1 | p1_e9y==1 |p2_e9y==1 |p3_e9y==1  | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)
				replace `x'prev7dhrstot_e = 0 if `x'prev7dhrstot_e ==. &  (p1_e5m ==1 | p2_e2wks==1 | p2_e2w2w==1| p1_e7m ==1  | p1_e12m ==1| p1_e13m ==1| p3_e2w==1 | p3_e5w==1 | p2_e12m ==1 | p2_e13m ==1 | p3_e12m ==1 | p3_e13m ==1 | p1_e9y==1 |p2_e9y==1 |p3_e9y==1  | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)
				replace `x'4whrstot_e  = 0 if `x'4whrstot_e==. & p1_e3wks ==1
				replace `x'4whrstot_b = 0 if `x'4whrstot_b==.
			}

			la var scavenge4whrstot_b  "Looking for scraps: Number of hrs in past month"
			la var beg4whrstot_b  "Beg: Number of hrs in past month"
			la var drugsell4whrstot_b  "Drug Selling: Number of hrs in past month"
			la var stealing4whrstot_b  "Stealing: Number of hrs in past month"
			la var gambling4whrstot_b  "Gambling: Number of hrs in past month"
			la var goldrubber4whrstot_b "Gold Mining and Rubber Tapping: Number of hrs in past month"

	// Incidence
		* NOTE * Watch out because at p2_e2wks, p2_e2w2w, p3_e2w, & p3_e5w we asked about the 4w but we only followup for 2w

		foreach x in shop table buysell pettytrade trade office carload carwash moto carryload guard houseclswp scavenge beg farm drugsell stealing  contract gambling smallbiz constr fish goldrubber other {
			count if (`x'7ddys_e == 0 & `x'prev7ddys_e ==0) & `x'4w_e ==1 & (p2_e2wks==1 | p2_e2w2w==1 | p3_e2w==1 | p3_e5w==1)
		}
		* Baseline p1 p2 p3
		* Endline all

		foreach x in shop table buysell pettytrade trade office carload carwash moto carryload guard houseclswp scavenge beg farm drugsell stealing  contract gambling smallbiz constr fish goldrubber other {
			gen `x'incidence_e = `x'4w_e if  p2_e2wks==1 | p2_e2w2w==1 | p1_e3wks ==1 | p3_e2w==1 | p3_e5w==1
			replace `x'incidence_e = `x'2w_e if p1_e5m ==1 | p1_e7m==1 | p1_e12m==1 | p1_e13m==1 | p2_e12m==1 | p2_e13m==1 | p3_e12m==1 | p3_e13m==1 |p1_e9y==1 |p2_e9y==1 |p3_e9y==1  | p1_e10y==1 | p2_e10y==1 | p3_e10y==1

			gen `x'incidence_b = `x'4w_b
			replace `x'incidence_b = 0 if `x'incidence_b ==. | `x'incidence_b ==.d
		}

			la var shopincidence_e "Had a Shop"
			la var tableincidence_e "Had a table at the market"
			la var buysellincidence_e "Did Buying and Selling around"
			la var pettytradeincidence_e "Did other petty trade"
			la var tradeincidence_e "Did Vocation"
			la var officeincidence_e "Did office work"
			la var carloadincidence_e   "Did Carloading"
			la var carwashincidence_e  "Did Car washing"
			la var motoincidence_e "Did Peim peim driving"
			la var carryloadincidence_e "Carried load for money"
			la var guardincidence_e "Did Watchman job"
			la var houseclswpincidence_e "Did brusshing clean cool house boy"
			la var scavengeincidence_e "Looked for scraps"
			la var begincidence_e "Begged"
			la var farmincidence_e "Farmed"
			la var drugsellincidence_e "Sold drugs"
			la var stealingincidence_e "Stole"
			la var gamblingincidence_e "Gambled"
			la var smallbizincidence_e "Had a small business (video or barber or shoeshine)"
			la var constrincidence_e "Did construction work"
			la var fishincidence_e "Did fishing"
			la var goldrubberincidence_e "Gold and rubber tapping"
			la var contractincidence_e "Did Contract Work"
			la var otherincidence_e "Other"

			la var shopincidence_b "Had a Shop"
			la var tableincidence_b "Had a table at the market"
			la var buysellincidence_b "Did Buying and Selling around"
			la var pettytradeincidence_b "Did other petty trade"
			la var tradeincidence_b "Did Vocation"
			la var officeincidence_b "Did office work"
			la var carloadincidence_b   "Did Carloading"
			la var carwashincidence_b  "Did Car washing"
			la var motoincidence_b "Did Peim peim driving"
			la var carryloadincidence_b "Carried load for money"
			la var guardincidence_b "Did Watchman job"
			la var houseclswpincidence_b "Did brusshing clean cool house boy"
			la var scavengeincidence_b "Looked for scraps"
			la var begincidence_b "Begged"
			la var farmincidence_b "Farmed"
			la var drugsellincidence_b "Sold drugs"
			la var stealingincidence_b "Stole"
			la var gamblingincidence_b "Gambled"
			la var smallbizincidence_b "Had a small business (video or barber or shoeshine)"
			la var constrincidence_b "Did construction work"
			la var fishincidence_b "Did fishing"
			la var goldrubberincidence_b "Gold and rubber tapping"
			la var contractincidence_b "Did Contract Work"
			la var otherincidence_b "Other"

		 * Categorisation
			* Baseline p1 p2 p3
			* Endline all

			foreach p in b e {

				gen illicitdum_`p' = (goldrubberincidence_`p'==1 |  drugsellincidence_`p'==1 | stealingincidence_`p'==1)
				replace illicitdum_`p' = . if goldrubberincidence_`p'==. & drugsellincidence_`p'==. &  stealingincidence_`p'==.
					la var illicitdum_`p' "Engaged in illicit activities"

				gen formaldum_`p' =(tradeincidence_`p' ==1 |  officeincidence_`p'==1 |  guardincidence_`p' ==1 )
				replace formaldum_`p' = . if tradeincidence_`p' ==. &  officeincidence_`p'==. &  guardincidence_`p' ==.
					la var formaldum_`p' "Engaged in formal/regular work"

				gen informaldum_`p' = (contractincidence_`p'==1 | farmincidence_`p' ==1 | shopincidence_`p'==1 |  tableincidence_`p'==1 | buysellincidence_`p'==1 | pettytradeincidence_`p'==1 |  carloadincidence_`p'==1 | carwashincidence_`p'==1 | motoincidence_`p'==1 | carryloadincidence_`p' ==1 | houseclswpincidence_`p'==1 | scavengeincidence_`p' ==1 | begincidence_`p' ==1 | gamblingincidence_`p' ==1 | smallbizincidence_`p' ==1 | constrincidence_`p'==1 |  fishincidence_`p'  ==1)
				replace informaldum_`p' = . if contractincidence_`p'==. &  farmincidence_`p' ==. &  shopincidence_`p'==. &   tableincidence_`p'==. &  buysellincidence_`p'==. &  pettytradeincidence_`p'==. &  carloadincidence_`p'==. &  carwashincidence_`p'==. &  motoincidence_`p'==. & carryloadincidence_`p' ==. &  houseclswpincidence_`p'==. &  scavengeincidence_`p' ==. &  begincidence_`p' ==. &  gamblingincidence_`p' ==. &  smallbizincidence_`p' ==. &  constrincidence_`p'==. &   fishincidence_`p'  ==.
					la var informaldum_`p' "Engaged in informal/self employment/petty labor"

				gen otherdum_`p' =(otherincidence_`p'==1)
				replace otherdum_`p' =. if otherincidence_`p'==.
					la var otherdum_`p' "Engaged in other activities"
			}


	// Sum across activities

		* Baseline p1 p2 p3
			egen hour4w_b = rowtotal (contract4whrstot_b shop4whrstot_b table4whrstot_b buysell4whrstot_b pettytrade4whrstot_b trade4whrstot_b office4whrstot_b carload4whrstot_b carwash4whrstot_b moto4whrstot_b carryload4whrstot_b guard4whrstot_b houseclswp4whrstot_b scavenge4whrstot_b beg4whrstot_b farm4whrstot_b drugsell4whrstot_b stealing4whrstot_b gambling4whrstot_b smallbiz4whrstot_b constr4whrstot_b fish4whrstot_b goldrubber4whrstot_b other4whrstot_b    ), missing
				replace hour4w_b = 0 if  hour4w_b ==.
				la var hour4w_b "Empl: Hours worked in past month"

		* Endline 2w 2w 3w 5m 7m 12m
			egen hour7d_e = rowtotal (contract7dhrstot_e shop7dhrstot_e table7dhrstot_e buysell7dhrstot_e pettytrade7dhrstot_e trade7dhrstot_e office7dhrstot_e carload7dhrstot_e carwash7dhrstot_e moto7dhrstot_e carryload7dhrstot_e guard7dhrstot_e houseclswp7dhrstot_e scavenge7dhrstot_e beg7dhrstot_e farm7dhrstot_e drugsell7dhrstot_e stealing7dhrstot_e gambling7dhrstot_e smallbiz7dhrstot_e constr7dhrstot_e fish7dhrstot_e goldrubber7dhrstot_e other7dhrstot_e ), missing
				replace hour7d_e = 0 if hour7d_e ==. & (p1_e3wks ==1 | p1_e5m==1 | p2_e2wks ==1 | p2_e2w2w ==1 | p1_e7m==1 | p1_e12m==1 | p1_e13m==1 | p3_e2w==1 | p3_e5w==1 | p2_e12m ==1 | p2_e13m ==1 | p3_e12m ==1 | p3_e13m ==1 |p1_e9y==1 |p2_e9y==1 |p3_e9y==1  | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)
				la var hour7d_e "Empl: Hours worked in past 7d"

				* Cap hours in 7d to 126 = 7*18
					replace hour7d_e = 126 if hour7d_e>126 & hour7d_e !=.

			* all but p1_e3wks
			egen hourprev7d_e = rowtotal (contractprev7dhrstot_e shopprev7dhrstot_e tableprev7dhrstot_e buysellprev7dhrstot_e pettytradeprev7dhrstot_e tradeprev7dhrstot_e officeprev7dhrstot_e carloadprev7dhrstot_e carwashprev7dhrstot_e motoprev7dhrstot_e carryloadprev7dhrstot_e guardprev7dhrstot_e houseclswpprev7dhrstot_e scavengeprev7dhrstot_e begprev7dhrstot_e farmprev7dhrstot_e drugsellprev7dhrstot_e stealingprev7dhrstot_e gamblingprev7dhrstot_e smallbizprev7dhrstot_e constrprev7dhrstot_e fishprev7dhrstot_e goldrubberprev7dhrstot_e otherprev7dhrstot_e ), missing
				replace hourprev7d_e = 0 if  hourprev7d_e ==.& (p1_e5m==1 | p2_e2wks ==1 | p2_e2w2w ==1 | p1_e7m==1 | p1_e12m==1 | p1_e13m==1| p3_e2w==1 | p3_e5w==1 | p2_e12m ==1 | p2_e13m ==1 | p3_e12m ==1 | p3_e13m ==1 |p1_e9y==1 |p2_e9y==1 |p3_e9y==1  | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)
				la var hourprev7d_e "Empl: Hours worked in past prev 7d"

				* Cap hours in 7d to 126 = 7*18
					replace hourprev7d_e = 126 if hourprev7d_e>126 & hourprev7d_e !=.

			* all but p1_e3wks
			egen houravg7d_e = rowmean (hour7d_e hourprev7d_e) if (p1_e5m==1 | p2_e2wks ==1 | p2_e2w2w ==1| p1_e7m==1 | p1_e12m==1 | p1_e13m==1 | p3_e2w==1 | p3_e5w==1 | p2_e12m ==1 | p2_e13m ==1 | p3_e12m ==1 | p3_e13m ==1|p1_e9y==1 |p2_e9y==1 |p3_e9y==1  | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)
				replace houravg7d_e = hour7d_e if p1_e3wks
 				la var houravg7d_e "Empl: Hours worked in past prev 7d (Avg)"

			* for p1_e3wks only
			egen hour4w_e = rowtotal (contract4whrstot_e shop4whrstot_e table4whrstot_e buysell4whrstot_e pettytrade4whrstot_e trade4whrstot_e office4whrstot_e carload4whrstot_e carwash4whrstot_e moto4whrstot_e carryload4whrstot_e guard4whrstot_e houseclswp4whrstot_e scavenge4whrstot_e beg4whrstot_e farm4whrstot_e drugsell4whrstot_e stealing4whrstot_e gambling4whrstot_e smallbiz4whrstot_e constr4whrstot_e fish4whrstot_e goldrubber4whrstot_e other4whrstot_e), missing
				replace hour4w_e = 0 if  hour4w_e ==. & (p1_e3wks ==1 )
				la var hour4w_e "Empl: Hours worked in past month"

		* Categorisation Endline 2w 2w 3w 5m 7m 12m 13m
			egen illicit7dhrstot_e = rowtotal(goldrubber7dhrstot_e drugsell7dhrstot_e  stealing7dhrstot_e), mi
			replace illicit7dhrstot_e = . if illicitdum_e==.
				la var illicit7dhrstot_e "Hours worked in illicit activities in past 7d"

			egen illicit7dhrsavg_e = rowmean(goldrubber7dhrstot_e drugsell7dhrstot_e  stealing7dhrstot_e)
			replace illicit7dhrsavg_e = 0 if illicitdum_e==.
				la var illicit7dhrsavg_e "Hours worked in illicit activities in past 7d (Avg)"



			egen formal7dhrstot_e =rowtotal(trade7dhrstot_e  office7dhrstot_e  guard7dhrstot_e), mi
			replace formal7dhrstot_e = . if formaldum_e==.
				la var formal7dhrstot_e "Hours worked in formal/regular work in past 7d"

			egen formal7dhrsavg_e =rowmean(trade7dhrstot_e  office7dhrstot_e  guard7dhrstot_e)
			replace formal7dhrsavg_e = 0 if formaldum_e==.
				la var formal7dhrsavg_e "Hours worked in formal/regular work in past 7d (Avg)"



			egen informal7dhrstot_e = rowtotal(contract7dhrstot_e farm7dhrstot_e shop7dhrstot_e table7dhrstot_e  buysell7dhrstot_e  pettytrade7dhrstot_e carload7dhrstot_e  carwash7dhrstot_e  moto7dhrstot_e  carryload7dhrstot_e   houseclswp7dhrstot_e  scavenge7dhrstot_e   beg7dhrstot_e   gambling7dhrstot_e   smallbiz7dhrstot_e   constr7dhrstot_e fish7dhrstot_e ), mi
			replace informal7dhrstot_e = . if informaldum_e==.
				la var informal7dhrstot_e "Hours worked in informal/self employment/petty labor in past 7d"

			egen informal7dhrsavg_e = rowmean(contract7dhrstot_e farm7dhrstot_e shop7dhrstot_e table7dhrstot_e  buysell7dhrstot_e  pettytrade7dhrstot_e carload7dhrstot_e  carwash7dhrstot_e  moto7dhrstot_e  carryload7dhrstot_e   houseclswp7dhrstot_e  scavenge7dhrstot_e   beg7dhrstot_e   gambling7dhrstot_e   smallbiz7dhrstot_e   constr7dhrstot_e fish7dhrstot_e )
			replace informal7dhrsavg_e = 0 if informaldum_e==.
				la var informal7dhrsavg_e "Hours worked in informal/self employment/petty labor in past 7d (Avg)"


			egen others7dhrstot_e =rowtotal(other7dhrstot_e), mi
			replace others7dhrstot_e = . if otherdum_e==.
				la var others7dhrstot_e "Hours worked in other activities in past 7d"


		* Categorisation Baseline
			egen illicit4whrstot_b = rowtotal(goldrubber4whrstot_b drugsell4whrstot_b  stealing4whrstot_b), mi
			replace illicit4whrstot_b = . if illicitdum_b==.
				la var illicit4whrstot_b "illicit activities (Hrs 1m)"

			egen illicit4whrsavg_b = rowmean(goldrubber4whrs_b drugsell4whrstot_b  stealing4whrstot_b)
			replace illicit4whrsavg_b = . if illicitdum_b==.
				la var illicit4whrsavg_b "illicit activities (Hrs 1m)"

			egen formal4whrstot_b =rowtotal(trade4whrstot_b  office4whrstot_b  guard4whrstot_b), mi
			replace formal4whrstot_b = . if formaldum_b==.
				la var formal4whrstot_b "formal/regular work (Hrs 1m)"

			egen formal4whrsavg_b =rowmean(trade4whrstot_b  office4whrstot_b  guard4whrstot_b)
			replace formal4whrsavg_b = . if formaldum_b==.
				la var formal4whrsavg_b "formal/regular work (Hrs 1m)"

			egen informal4whrstot_b = rowtotal(contract4whrstot_b farm4whrstot_b shop4whrstot_b table4whrstot_b  buysell4whrstot_b  pettytrade4whrstot_b carload4whrstot_b  carwash4whrstot_b  moto4whrstot_b  carryload4whrstot_b   houseclswp4whrstot_b  scavenge4whrstot_b   beg4whrstot_b   gambling4whrstot_b   smallbiz4whrstot_b   constr4whrstot_b fish4whrstot_b ), mi
			replace informal4whrstot_b = . if informaldum_b==.
				la var informal4whrstot_b "informal/self employment/petty labor  (Hrs 1m)"

			egen informal4whrsavg_b = rowmean(contract4whrstot_b farm4whrstot_b shop4whrstot_b table4whrstot_b  buysell4whrstot_b  pettytrade4whrstot_b carload4whrstot_b  carwash4whrstot_b  moto4whrstot_b  carryload4whrstot_b   houseclswp4whrstot_b  scavenge4whrstot_b   beg4whrstot_b   gambling4whrstot_b   smallbiz4whrstot_b   constr4whrstot_b fish4whrstot_b )
			replace informal4whrsavg_b = . if informaldum_b==.
				la var informal4whrsavg_b "informal/self employment/petty labor  (Hrs 1m)"

			egen others4whrstot_b =rowtotal(other4whrstot_b), mi
			replace others4whrstot_b = . if otherdum_b==.
				la var others4whrstot_b "other activities  (Hrs 1m)"
